home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The PC-SIG Library 10
/
The PC-Sig Library - Shareware for the IBM PC and Compatibles (PC-SIG)(Tenth Edition Disks 1-2804)(1991).iso
/
PC_SIGCD
/
26
/
3
/
DISK2631.ZIP
/
EXAMP1.ZIP
/
UMEX301.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-03-29
|
1KB
|
38 lines
; User's Manual Example, Page 301.
;
; Changed name from "sum.asm" to "umex301.asm"
; Relates to "umex300.bas".
code segment byte
assume cs:code
; si,di,ds,bp,sp,ss must be preserved
; long integer result is returned in dx:ax
suminteger proc far
public suminteger
push bp ;bp must be preserved
mov bp, sp ;create a parameter stack frame
push ds ;ds must be preserved
xor ax, ax ;zero the low-order result
xor dx, dx ;zero the high-order result
lds bx, [bp] [06] ;get a pointer to the count
mov cx, [bx] ;cx = count of array elements
lds bx, [bp] [10] ;ds:[bx] = pointer to first element
jcxz sum2 ;in case of zero elements
sum1:
add ax, ds:[bx] ;add in one integer
adc dx, 0 ;account for possible integer overflow
add bx, 2 ;point to the next integer
loop sum1 ;repeat as necessary
sum2:
pop ds ;restore the caller's registar
pop bp
retf 8 ;clear 8 bytes of parameters
suminteger endp
code ends
end